home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 10 Aug 98
- // Author: mw
- //
- // Procedure Name:
- // doBakeSimulationArgList
- //
- // Description:
- // This is the actual function that calls from the "Bake Simulation"
- // option box.
- //
- // Input Arguments:
- // $version: The version of this option box. Used to know how to
- // interpret the $args array.
- // "1" : $useTS, $start, $end, $by, $below, $control, $shapes, $imp, $useCB
- // "2" : $preserveOutsideKeys
- // "3" : $selectionConnection
- //
- // $args
- // Version 1
- // [0] $whichRange 1 : use the playback range
- // !(1) : use the $start and $end values
- // [1] $start only applicable if $whichRange is 2
- // [2] $end only applicable if $whichRange is 2
- // [3] $by the increment from start to end time of simulation
- // with which to view frames and capture keyframes
- // [4] $below 0/1 : bake on selected items only, or all below
- // [5] $control 0/1 : if 1 and a transform above a shape is selected,
- // bake animation of all control points also
- // [6] $shapes 0/1 : if 1 and a transform above a shape is selected,
- // bake attributes of shape as well
- // (excluding control points)
- // [7] $imp 0/1 : if we're baking attributes that are controlled by an
- // implicit animation (i.e. with no explicit DG connections),
- // then if 1, turn off this implicit control after the
- // bake is complete (e.g. turn off the IK handle's
- // effects after baking skeleton joints, controlled by IK)
- // [8] $useCB 0/1 : if 1, set keyframes on attrs specified in channel box
- // Version 2
- // [9] $preserveOutsideKeys 0/1 : if 1, preserve keys that are ouside the bake
- // range when there are directly connected anim
- // curves
- // Version 3
- // [10] $selectionConnection name of selection connection to use
- // [11] $sparseAnimCurveBake 0 : insert a key at every time step
- // 1 : do not insert new keys into ranges
- // where animation is defined, and try to
- // use as few keys as possible to bake the
- // pre and post infinity behavior
- //
- // Return Value:
- // None
- //
- global proc doBakeSimulationArgList (string $version, string $args[])
- {
- int $versionNum = $version;
-
- int $whichRange = $args[0];
- float $start = $args[1];
- float $end = $args[2];
- float $by = $args[3];
- int $below = $args[4];
- int $control = $args[5];
- int $shapes = $args[6];
- int $imp = $args[7];
- int $useCB = $args[8];
- int $preserveOutsideKeys = ($versionNum >= 2 ? $args[9] : 0);
- string $selectionConnection = ($versionNum >= 3 ? $args[10] : "animationList");
- int $sparseAnimCurveBake = ($versionNum >= 3 ? $args[11] : 0);;
-
- string $cmd = "bakeResults -simulation true";
-
- if ($whichRange == 1 ) {
- $cmd = ($cmd +
- " -t \"" + `playbackOptions -query -minTime` + ":" +
- `playbackOptions -query -maxTime` + "\"");
- }
- else {
- $cmd = ($cmd + " -t \"" + $start + ":" + $end + "\"");
-
-
- }
-
- // Hierarchy election
- //
- if ($below) {
- $cmd = $cmd + " -hierarchy below";
- }
-
- // Sample By
- //
- $cmd = ( $cmd + " -sampleBy " + $by );
-
- // Disable Implicit Control
- //
- if ($imp)
- $cmd = ($cmd + " -disableImplicitControl true");
- else
- $cmd = ($cmd + " -disableImplicitControl false");
-
- // Keep Unbaked Keys
- //
- if ($preserveOutsideKeys)
- $cmd = ($cmd + " -preserveOutsideKeys true");
- else
- $cmd = ($cmd + " -preserveOutsideKeys false");
-
- // Sparse AnimCurve Bake
- //
- if ($sparseAnimCurveBake)
- $cmd = ($cmd + " -sparseAnimCurveBake true");
- else
- $cmd = ($cmd + " -sparseAnimCurveBake false");
-
- // The Channel Box option determines both attributes AND target
- // objects.
- //
- if( $useCB ) {
- string $syntax[] = keySetOptionBoxCommon( { "bakeSimulation",
- "unknown",
- "channelBoxSyntax" } );
- if( size( $syntax[0] ) == 0 ) {
- warning("No channels selected in channel box");
- return;
- }
-
- $cmd = ( $cmd + $syntax[0] );
- }
- // control points & shape options only applicable without
- // explicit channel box selection of attributes
- //
- else {
- // Control points, shapes, elections
- //
- if ($control)
- $cmd = ( $cmd + " -controlPoints true" );
- else
- $cmd = ( $cmd + " -controlPoints false" );
-
- if ($shapes)
- $cmd = ($cmd + " -shape true");
- else
- $cmd = ($cmd + " -shape false");
-
- // Get the target objects
- //
- string $members = expandSelectionConnection ($selectionConnection);
-
- if( $members == "" ) {
- $cmd = $cmd + " -animation objects";
- }
- else {
- if ($members == "{}") {
- $cmd = "";
- warning ("No objects selected to bake simulation");
- }
- else {
- $cmd = ($cmd + " " + $members);
- }
- }
- }
-
- if ($cmd != "") {
- evalEcho($cmd);
- }
- }
-